package com.robot.controller;

import com.robot.dao.dto.CategoryDTO;
import com.robot.dao.dto.IDDTO;
import com.robot.common.result.Response;
import com.robot.service.CategoryService;

import com.robot.dao.vo.CategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
@Slf4j
@Api(tags = "类目相关接口")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @PostMapping("/queryByEnterpriseId")
    @ApiOperation("根据企业ID查询类目列表")
    public Response<List<CategoryVO>> queryByEnterpriseId(@RequestBody IDDTO iddto){
        List<CategoryVO> categoryVOS = categoryService.queryByEnterpriseId(iddto);
        return Response.success(categoryVOS);
    }


    @PostMapping("/create")
    @ApiOperation("创建新类目")
    public Response<CategoryVO> createCategory(@RequestBody CategoryDTO categoryDTO){
        CategoryVO categoryVO = categoryService.create(categoryDTO);
        return Response.success(categoryVO);
    }


}
